# Autoconf script
# Inspired by a script provided by Alex Ott
# 2004,2005 - Daniel Barron
# 2011 - Some improvements and corrections by MinD Team


AC_PREREQ(2.57)
AC_INIT(mind, 1.0)
AM_INIT_AUTOMAKE
AC_CONFIG_HEADERS([mind_config.h])

AC_CACHE_LOAD

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_LANG_C
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LIBTOOL

AC_LANG(C++)

AC_CACHE_SAVE

# Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stdlib.h])
AC_CHECK_HEADERS([string.h sys/socket.h sys/time.h syslog.h unistd.h locale.h])
AC_CHECK_HEADERS([sys/types.h sys/un.h sys/poll.h sys/resource.h])
AC_CHECK_HEADERS([pwd.h grp.h])
AC_CHECK_HEADERS([byteswap.h])

AC_CHECK_LIB(socket, socket, [LIBSOCKET="-lsocket"])
AC_SUBST(LIBSOCKET)

AC_CHECK_LIB(nsl, inet_ntoa, [LIBNSL="-lnsl"])
AC_CHECK_LIB(nsl, gethostbyname, [LIBNSL="-lnsl"])
AC_SUBST(LIBNSL)

AM_PATH_XML2(2.6.0,CFLAGS="$CFLAGS $XML_CPPFLAGS"; LDFLAGS="$LDFLAGS $XML_LIBS",exit 1)

AC_CACHE_SAVE

csoap_release=1
csoap_version=1
AC_SUBST(csoap_release)
AC_SUBST(csoap_version)

nanohttp_version=1
AC_SUBST(nanohttp_version)


AC_FUNC_MALLOC
AC_FUNC_VPRINTF
AC_FUNC_STRFTIME
AC_FUNC_SELECT_ARGTYPES
AC_CHECK_FUNCS([gethostbyname inet_ntoa memmove memset mkdir select socket strchr strdup strncasecmp strpbrk strspn strstr strtol])


# Check system endianness
AC_C_BIGENDIAN

# check for zlib
AC_MSG_CHECKING(if zlib should be statically linked)
AC_ARG_ENABLE(static-zlib,
[AC_HELP_STRING([--enable-static-zlib@<:@=no@:>@], [Enable static linking of zlib])],
[ if test "x$enableval" = "xno"; then
	staticzlib=false
	AC_MSG_RESULT(no)
else
	staticzlib=true
	AC_MSG_RESULT(yes)
fi
],
[
staticzlib=false
AC_MSG_RESULT(no)
])

AC_MSG_CHECKING(for zlib)
AC_ARG_WITH(zlib,
	[AC_HELP_STRING([--with-zlib@<:@=NONE@:>@], [non-standard search path for zlib library])],
	[ # check for header & func (in library) in given prefix
	CPPFLAGS="${CPPFLAGS} -I${withval}/include"
	if test "x$staticzlib" = "xtrue"; then
		LIBS="-Bstatic -L${withval} -lz -Bdynamic ${LIBS}"
	else
		LIBS="-L${withval}/lib -lz ${LIBS}"
	fi
	],
	[ # if --with-zlib is not supplied, we still need -lz in LIBS.
	if test "x$staticzlib" = "xtrue"; then
		LIBS="-Bstatic -lz -Bdynamic ${LIBS}"
	else
		LIBS="-lz ${LIBS}"
	fi
	])
AC_CHECK_HEADERS([zlib.h])
if ! test "x$staticzlib" = "xtrue"; then
	AC_CHECK_LIB(z, gzdopen, [AC_MSG_RESULT(yes)], [AC_MSG_ERROR([no zlib!])])
fi

AC_CACHE_SAVE

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_OFF_T
AC_TYPE_UID_T

# Checks for library functions.
AC_FUNC_FORK
AC_CHECK_FUNCS([dup2 gettimeofday memset select])
AC_CHECK_FUNCS([strerror strstr strtol])
AC_CHECK_FUNCS([setuid setgid umask seteuid setreuid setlocale])
AC_SEARCH_LIBS([floor], [m])
AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_SEARCH_LIBS([socket], [socket], [], [
	AC_CHECK_LIB(
		[socket], [socket], [LIBS="-lsocket -lnsl $LIBS"],
		[], [-lnsl]
	)
])
AC_SEARCH_LIBS([inet_aton], [resolv])

AC_CACHE_SAVE

AC_MSG_CHECKING(for backside with both hands)
AC_MSG_RESULT(no)
AC_MSG_CHECKING(build os)
AC_CANONICAL_BUILD
AC_MSG_RESULT($build_os)

AC_MSG_CHECKING(for debug option)
AC_ARG_WITH(dgdebug,
[AC_HELP_STRING([--with-dgdebug@<:@=off@:>@], [switch on debug build mode])],
[if test "x${withval}" == "xoff" ; then
  AC_MSG_RESULT(no)
else
  AC_MSG_RESULT(yes)
  dgdebug=${withval}
  AC_DEFINE(MIND_DEBUG, 1, [Define to enable debug build mode])
fi], [
  # disable by default
  AC_MSG_RESULT(no)
])


AC_MSG_CHECKING(for proxy user)
AC_ARG_WITH(proxyuser,
[AC_HELP_STRING([--with-proxyuser@<:@=nobody@:>@], [name of proxy user])],
[if test "x${withval}" != "x" ; then
  AC_MSG_RESULT(yes)
  proxyuser=${withval}
else
  AC_MSG_RESULT(no)
  proxyuser=nobody
fi], [
  # disable by default
  AC_MSG_RESULT(no)
  proxyuser=nobody
])
AC_SUBST(DGPROXYUSER, "$proxyuser")

AC_MSG_CHECKING(for proxy group)
AC_ARG_WITH(proxygroup,
[AC_HELP_STRING([--with-proxygroup@<:@=nobody@:>@], [name of proxy group])],
[if test "x${withval}" != "x" ; then
  AC_MSG_RESULT(yes)
  proxygroup=${withval}
else
  AC_MSG_RESULT(no)
  proxygroup=nobody
fi], [
  # disable by default
  AC_MSG_RESULT(no)
  proxygroup=nobody
])
AC_SUBST(DGPROXYGROUP, "$proxygroup")

AC_MSG_CHECKING(for piddir)
AC_ARG_WITH(piddir,
[AC_HELP_STRING([--with-piddir@<:@=PREFIX/LOCALSTATEDIR/run@:>@], [path for pid file])],
[if test "x${withval}" != "x" ; then
  AC_MSG_RESULT(yes)
  piddir=${withval}
else
  AC_MSG_RESULT(no)
  piddir="${localstatedir}/run"
fi], [
  # disable by default
  AC_MSG_RESULT(no)
  piddir="${localstatedir}/run"
])
AC_FINALIZE_VAR(DGPIDDIR,"$piddir")
AC_SUBST(DGPIDDIR)


AC_MSG_CHECKING(for logdir)
AC_ARG_WITH(logdir,
[AC_HELP_STRING([--with-logdir@<:@=PREFIX/LOCALSTATEDIR/log/mind@:>@], [path for log files])],
[if test "x${withval}" != "x" ; then
  AC_MSG_RESULT(yes)
  logdir=${withval}
else
  AC_MSG_RESULT(no)
  logdir="${localstatedir}/log/${PACKAGE_NAME}"
fi], [
  # disable by default
  AC_MSG_RESULT(no)
  logdir="${localstatedir}/log/${PACKAGE_NAME}"
])
AC_FINALIZE_VAR(DGLOGLOCATION,"$logdir")
AC_SUBST(DGLOGLOCATION)


AC_MSG_CHECKING(for listdir)
AC_ARG_WITH(listdir,
[AC_HELP_STRING([--with-listdir@<:@=PREFIX/LOCALSTATEDIR/mind/lists@:>@], [path for URLs/phrases lists files])],
[if test "x${withval}" != "x" ; then
  AC_MSG_RESULT(yes)
  listdir=${withval}
else
  AC_MSG_RESULT(no)
  listdir="${localstatedir}/${PACKAGE_NAME}/lists"
fi], [
  # disable by default
  AC_MSG_RESULT(no)
  listdir="${localstatedir}/${PACKAGE_NAME}/lists"
])
AC_FINALIZE_VAR(MIND_LIST_LOCATION,"$listdir")
AC_SUBST(MIND_LIST_LOCATION)


PKG_PROG_PKG_CONFIG

# asking user if they want PCRE support
AC_MSG_CHECKING(for PCRE support)
AC_ARG_ENABLE(
pcre,
[AC_HELP_STRING([--enable-pcre@<:@=yes@:>@], [Enable support for the PCRE library])],
[ if test "x$enableval" = "xno"; then
	pcre=false
	AC_MSG_RESULT(no)
else
	pcre=true
	AC_MSG_RESULT(yes)
fi
],
[ # enable by default
	pcre=true
	AC_MSG_RESULT(yes)
]
)
if test "x$pcre" = "xtrue"; then
	PKG_CHECK_MODULES([PCRE],[libpcre >= 6.0])
	AC_DEFINE([HAVE_PCRE],[],[Define to enable PCRE support])
	PCRE_LIBS="-lpcreposix ${PCRE_LIBS}"
else
	AC_CHECK_FUNCS([regcomp])
fi
AM_CONDITIONAL(HAVE_PCRE, test "x$pcre" = "xtrue")

# ask user if they want a backtrace logged after segfault
AC_MSG_CHECKING(for backtrace on segfault support)
AC_ARG_ENABLE(
segv_backtrace,
[AC_HELP_STRING([--enable-segv-backtrace@<:@=no@:>@], [Enable logging a backtrace when a segmentation fault occurs])],
[ if test "x$enableval" = "xno"; then
	AC_MSG_RESULT(no)
else
	# check for native header & func (no library)
	AC_CHECK_FUNCS(backtrace, [AC_MSG_RESULT(native)], [
		AC_MSG_RESULT(no)
		# native not found, so look for linked
		LIBS="-lexecinfo ${LIBS}"
		AC_CHECK_LIB(execinfo, backtrace, [
			AC_MSG_RESULT(linked)
		], [
			AC_MSG_RESULT(no)
			AC_MSG_ERROR([no native or standard library backtrace function found! (needed by "--enable-segv-backtrace")])
		])
	])
	AC_DEFINE([ENABLE_SEGV_BACKTRACE],[],[Define to enable backtrace on segmentation fault])
	# add -rdynamic to compiler flags to force output of symbol tables
	CXXFLAGS="-rdynamic ${CXXFLAGS}"
fi
],
[ # disable by default
	AC_MSG_RESULT(no)
])

# ask user if they want large file support on 32 bit systems
AC_MSG_CHECKING([for large file support])
AC_ARG_ENABLE(
lfs,
[AC_HELP_STRING([--enable-lfs@<:@=yes@:>@], [Enable large file support on 32 bit systems])],
[ if test "x$enableval" = "xno"; then
	AC_MSG_RESULT(no)
else
	lfsflags=`getconf LFS_CFLAGS`
	lfsld=`getconf LFS_LDFLAGS`
	lfslib=`getconf LFS_LIBS`
	CXXFLAGS="${CXXFLAGS} $lfsflags"
	LDFLAGS="${LDFLAGS} $lfsld"
	LIBS="${LIBS} $lfslib"
	AC_MSG_RESULT(yes)
fi
],
[ # enable by default
	lfsflags=`getconf LFS_CFLAGS`
	lfsld=`getconf LFS_LDFLAGS`
	lfslib=`getconf LFS_LIBS`
	CXXFLAGS="${CXXFLAGS} $lfsflags"
	LDFLAGS="${LDFLAGS} $lfsld"
	LIBS="${LIBS} $lfslib"
	AC_MSG_RESULT(yes)
])

# ask the user if they want support for retrieving original destination IPs
# when acting as a transparent proxy
AC_MSG_CHECKING([for original destination IP checking support])
AC_ARG_ENABLE(
orig-ip,
[AC_HELP_STRING([--enable-orig-ip@<:@=no@:>@], [Enable support for checking the client's original destination IP address against HTTP request details when deployed as a transparent proxy (US-CERT VU@%:@435052).  Currently only works on Linux.])],
[ if test "x$enableval" = "xno"; then
	AC_MSG_RESULT(no)
	origip=false
	ORIGIPSUPPORT="#!! Not compiled !! "
else
	AC_MSG_RESULT(yes)
	origip=true
	AC_DEFINE([ENABLE_ORIG_IP],[],[Define to enable original destination IP checking])
	ORIGIPSUPPORT=""
fi
],
[ # disable by default
	AC_MSG_RESULT(no)
	origip=false
	ORIGIPSUPPORT="#!! Not compiled !! "
])
AC_SUBST(ORIGIPSUPPORT)

# determine whether or not "off_t" is simply a typedef of
# "int", "unsigned int", "long", etc. - if it is, the String
# class won't compile if its off_t constructor is defined,
# as that would represent a function redefinition.
AC_MSG_CHECKING([for type collision with off_t])
AC_COMPILE_IFELSE(
[
 AC_LANG_PROGRAM(
 [[#include <sys/types.h>]],[[
 struct Foo{
 	void f(const int);
	void f(const long);
	void f(const long unsigned);
	void f(const unsigned int);
	void f(const off_t);
 };]])
],[
   AC_MSG_RESULT([no])
],[
   AC_MSG_RESULT([yes])
   AC_DEFINE([OFFT_COLLISION],[],[Define if type "off_t" is a typedef of another type for which String already has a constructor])
])

# by default, we do not need the content scanner list or config directories, nor the download manager list directory
cslists=false
csconfigs=false
dmlists=false

# asking user if they want clamav support
AC_MSG_CHECKING(for libclamav support)
AC_ARG_ENABLE(
clamav,
[AC_HELP_STRING([--enable-clamav@<:@=no@:>@], [Enable support for the libClamAV content scanner. Please note that the ClamD-compatible scanner is always built, and is preferable to this plugin for most usage scenarios.])],
[ if test "x$enableval" = "xno"; then
	clamav=false
	AC_MSG_RESULT(no)
	CLAMAVSUPPORT="!! Not compiled !! "
	CLAMAVSHM="!! Not supported on this platform !!"
else
	AC_MSG_RESULT(yes)
	PKG_CHECK_MODULES([CLAMAV],[libclamav >= 4])

	AC_DEFINE([HAVE_CLAMAV],[],[Define to enable ClamAV content scanner])
	
	# check for shm_open (& shm_unlink)
	AC_CHECK_HEADERS([sys/mman.h])
	AC_CHECK_FUNCS([shm_open])
	if test "x$ac_cv_func_shm_open" = "xno"; then
		AC_CHECK_LIB(rt, shm_open, [
			AC_MSG_RESULT(yes)
			AC_DEFINE([HAVE_CLAMAV_SHM],[],[Define to enable POSIX Shared Memory support in ClamAV content scanner])
			LIBS="-lrt ${LIBS}"
			CLAMAVSHM=""
		], [
			AC_MSG_RESULT(no)
			CLAMAVSHM="!! Not supported on this platform !!"
		])
	fi

	clamav=true
	cslists=true
	csconfigs=true
	CLAMAVSUPPORT=""
fi
],
[ #disable by default
 	clamav=false
	AC_MSG_RESULT(no)
	CLAMAVSUPPORT="!! Not compiled !! "
	CLAMAVSHM="!! Not supported on this platform !!"
]
)
AM_CONDITIONAL(HAVE_CLAMAV, test "x$clamav" = "xtrue")
AC_SUBST(CLAMAVSUPPORT)
AC_SUBST(CLAMAVSHM)

# asking user if they want clamd support
AC_MSG_CHECKING(for clamd support)
AC_ARG_ENABLE(
clamd,
[AC_HELP_STRING([--enable-clamd@<:@=no@:>@], [Enable support for the ClamD content scanner])],
[ if test "x$enableval" = "xno"; then
	AC_MSG_RESULT(no)
	clamd=false
	CLAMDSUPPORT="!! Not compiled !! "
else
	AC_MSG_RESULT(yes)
	clamd=true
	cslists=true
	csconfigs=true
	CLAMDSUPPORT=""
	AC_DEFINE([ENABLE_CLAMD],[],[Define to enable ClamD content scanner])
fi],
[
	AC_MSG_RESULT(no)
	clamd=false
	CLAMDSUPPORT="!! Not compiled !! "
]
)
AM_CONDITIONAL(ENABLE_CLAMD, test "x$clamd" = "xtrue")
AC_SUBST(CLAMDSUPPORT)

# asking user if they want icap support
AC_MSG_CHECKING(for icap support)
AC_ARG_ENABLE(
icap,
[AC_HELP_STRING([--enable-icap@<:@=no@:>@], [Enable support for ICAP AV server content scanner])],
[ if test "x$enableval" = "xno"; then
	AC_MSG_RESULT(no)
	icap=false
	ICAPSUPPORT="!! Not compiled !! "
else
	AC_MSG_RESULT(yes)
	icap=true
	cslists=true
	csconfigs=true
	AC_DEFINE([ENABLE_ICAP],[],[Define to enable ICAP content scanner])
	ICAPSUPPORT=""
fi],
[
	AC_MSG_RESULT(no)
	icap=false
	ICAPSUPPORT="!! Not compiled !! "
]
)
AM_CONDITIONAL(ENABLE_ICAP, test "x$icap" = "xtrue")
AC_SUBST(ICAPSUPPORT)

# asking user if they want kavd support
AC_MSG_CHECKING(for kavd support)
AC_ARG_ENABLE(
kavd,
[AC_HELP_STRING([--enable-kavd@<:@=no@:>@], [Enable support for the Kaspersky AV daemon content scanner])],
[ if test "x$enableval" = "xno"; then
	AC_MSG_RESULT(no)
	kavd=false
	KAVDSUPPORT="!! Not compiled !! "
else
	AC_MSG_RESULT(yes)
	kavd=true
	cslists=true
	csconfigs=true
	KAVDSUPPORT=""
	AC_DEFINE([ENABLE_KAVD],[],[Define to enable KAVD content scanner])
fi],
[
	AC_MSG_RESULT(no)
	kavd=false
	KAVDSUPPORT="!! Not compiled !! "
]
)
AM_CONDITIONAL(ENABLE_KAVD, test "x$kavd" = "xtrue")
AC_SUBST(KAVDSUPPORT)

dnl detecting kaspersky antivirus client
#KAV_PATH_KAVCLIENT
#AM_CONDITIONAL(HAVE_KAVCLIENT, test "x$kavclient_found" = "xyes")
#kav stuff is not finished Wed 09th February 2005 - DB
KAVAVSUPPORT="!! Unimplemented !! "
AC_SUBST(KAVAVSUPPORT)

# asking user if they want command-line content scanner support
AC_MSG_CHECKING(for command-line content scanner support)
AC_ARG_ENABLE(
commandline,
[AC_HELP_STRING([--enable-commandline@<:@=no@:>@], [Enable support for command-line content scanners])],
[ if test "x$enableval" = "xno"; then
	AC_MSG_RESULT(no)
	commandline=false
	COMMANDLINESUPPORT="!! Not compiled !! "
else
	AC_MSG_RESULT(yes)
	commandline=true
	cslists=true
	csconfigs=true
	COMMANDLINESUPPORT=""
	AC_DEFINE([ENABLE_COMMANDLINE],[],[Define to enable command-line content scanner])
fi],
[
	AC_MSG_RESULT(no)
	commandline=false
	COMMANDLINESUPPORT="!! Not compiled !! "
])
AM_CONDITIONAL(ENABLE_COMMANDLINE, test "x$commandline" = "xtrue")
AC_SUBST(COMMANDLINESUPPORT)

# install CS configs and lists if necessary
AM_CONDITIONAL(NEED_CSLISTS, test "x$cslists" = "xtrue")
AM_CONDITIONAL(NEED_CSCONFIGS, test "x$csconfigs" = "xtrue")

# asking user if they want fancy downloadmanager support
AC_MSG_CHECKING(for fancy download manager support)
AC_ARG_ENABLE(
fancydm,
[AC_HELP_STRING([--enable-fancydm@<:@=yes@:>@], [Enable support for the fancy download manager])],
[ if test "x$enableval" = "xno"; then
	fancydm=false
	FANCYSUPPORT="#!! Not compiled !! "
	AC_MSG_RESULT(no)
else
	AC_MSG_RESULT(yes)
	fancydm=true
	dmlists=true
	FANCYSUPPORT=""
	AC_DEFINE([ENABLE_FANCYDM],[],[Define to enable fancy download manager])
fi],
[
	fancydm=true
	dmlists=true
	FANCYSUPPORT=""
	AC_MSG_RESULT(yes)
	AC_DEFINE([ENABLE_FANCYDM],[],[Define to enable fancy download manager])
]
)
AM_CONDITIONAL(ENABLE_FANCYDM, test "x$fancydm" = "xtrue")
AC_SUBST(FANCYSUPPORT)

# asking user if they want trickle downloadmanager support
AC_MSG_CHECKING(for trickle download manager support)
AC_ARG_ENABLE(
trickledm,
[AC_HELP_STRING([--enable-trickledm@<:@=no@:>@], [Enable support for the trickle download manager])],
[ if test "x$enableval" = "xno"; then
	trickledm=false
	TRICKLESUPPORT="#!! Not compiled !! "
	AC_MSG_RESULT(no)
else
	AC_MSG_RESULT(yes)
	trickledm=true
	dmlists=true
	TRICKLESUPPORT=""
	AC_DEFINE([ENABLE_TRICKLEDM],[],[Define to enable trickle download manager])
fi],
[
	trickledm=false
	TRICKLESUPPORT="#!! Not compiled !! "
	AC_MSG_RESULT(no)
]
)
AM_CONDITIONAL(ENABLE_TRICKLEDM, test "x$trickledm" = "xtrue")
AC_SUBST(TRICKLESUPPORT)

# install DM lists if necessary
AM_CONDITIONAL(NEED_DMLISTS, test "x$dmlists" = "xtrue")

# asking user if they want NTLM auth support
AC_MSG_CHECKING(for NTLM support)
AC_ARG_ENABLE(
ntlm,
[AC_HELP_STRING([--enable-ntlm@<:@=no@:>@], [Enable support for the NTLM auth plugin])],
[ if test "x$enableval" = "xno"; then
	AC_MSG_RESULT(no)
	ntlm=false
	NTLMSUPPORT="!! Not compiled !! "
else
	AC_MSG_RESULT(yes)
	ntlm=true
	NTLMSUPPORT=""
	AC_DEFINE([ENABLE_NTLM],[],[Define to enable NTLM auth plugin])
	# now need to check if they're using an iconv library, rather
	# than a native iconv implementation
	AC_ARG_WITH(libiconv,
		[AC_HELP_STRING([--with-libiconv@<:@=NONE@:>@], [Specify search path on a system which requires an external iconv library (only used in conjunction with NTLM auth plugin).])],
		[ # check for header & func (in library) in given prefix
			if test "x$withval" != "x"; then
				CPPFLAGS="${CPPFLAGS} -I${withval}/include"
				LIBS="-L${withval}/lib -liconv ${LIBS}"
			else
				LIBS="-liconv ${LIBS}"
			fi
			AC_CHECK_LIB(iconv, iconv, [AC_MSG_RESULT(linked)], [
				AC_MSG_RESULT(no)
				AC_CHECK_LIB(iconv, libiconv, [AC_MSG_RESULT(linked)], [
					AC_MSG_ERROR([no libiconv found in given search path! (needed by NTLM plugin)])
				])
			])
		],
		[ # check for native header & func (no library)
			AC_CHECK_FUNCS(iconv, [AC_MSG_RESULT(native)], [
				AC_MSG_RESULT(no)
				# native not found, so look for linked
				LIBS="-liconv ${LIBS}"
				AC_CHECK_LIB(iconv, iconv, [
					AC_MSG_RESULT(linked)
				], [
					AC_MSG_RESULT(no)
					AC_CHECK_LIB(iconv, libiconv, [AC_MSG_RESULT(linked)], [
						AC_MSG_ERROR([no native or standard library iconv function found! (needed by NTLM plugin - try again with "--with-libiconv"?)])
					])
				])
			])
		]
	)
fi],
[
	AC_MSG_RESULT(no)
	ntlm=false
	NTLMSUPPORT="!! Not compiled !! "
]
)
AM_CONDITIONAL(ENABLE_NTLM, test "x$ntlm" = "xtrue")
AC_SUBST(NTLMSUPPORT)


# Getting revision number
export revision=$(LANG=C svn info | grep Revision )
AC_DEFINE_UNQUOTED([MIND_REVISION], ["$revision"], [Mind Rev. number])

# Defining Code Name / SLC State
AC_DEFINE_UNQUOTED([MIND_CODENAME], ["Toy"], [Mind codename])
AC_DEFINE_UNQUOTED([MIND_SLC_STATE], ["BETA"], [Mind codename])

# asking the user if they want email notifications
AC_MSG_CHECKING(for email notification support)
AC_ARG_ENABLE(
email,
[AC_HELP_STRING([--enable-email@<:@=no@:>@], [Enable support for email reporting functionality])],
[ if test "x$enableval" = "xyes"; then
	email=true
	EMAILSUPPORT=""
	AC_MSG_RESULT(yes)
	AC_DEFINE([ENABLE_EMAIL],[],[Define to enable email reporting])
else
	email=false
	EMAILSUPPORT="#!! Not compiled !!"
	AC_MSG_RESULT(no)
fi],
[
	email=false
	EMAILSUPPORT="#!! Not compiled !!"
	AC_MSG_RESULT(no)
])
AC_SUBST(EMAILSUPPORT)

AC_DEFINE_UNQUOTED([MIND_CONFIGURE_OPTIONS], ["$ac_configure_args"], [Record configure-time options])

libdir="${libdir}/${PACKAGE_NAME}"

AC_ARG_WITH(sysconfsubdir,
	[AC_HELP_STRING([--with-sysconfsubdir@<:@=mind@:>@], [subdirectory under sysconfdir in which to place config files])],
	[if test "x$withval" != "x"; then
		dgsysconfdir="${sysconfdir}/${withval}"
	else
		dgsysconfdir="${sysconfdir}"
	fi],
	[dgsysconfdir="${sysconfdir}/${PACKAGE_NAME}"])

AC_FINALIZE_VAR(DGLIBDIR,"${libdir}")
AC_SUBST(DGLIBDIR)
AC_FINALIZE_VAR(DGBINDIR,"${sbindir}")
AC_SUBST(DGBINDIR)
AC_FINALIZE_VAR(DGCONFDIR,"${dgsysconfdir}")
AC_SUBST(DGCONFDIR)
AC_FINALIZE_VAR(DGDATADIR,"${datadir}/${PACKAGE_NAME}")
AC_SUBST(DGDATADIR)
AC_FINALIZE_VAR(DGCONFFILE,"${dgsysconfdir}/${PACKAGE_NAME}.conf")
AC_SUBST(DGCONFFILE)

AC_CONFIG_FILES([Makefile
	        data/Makefile
	        data/languages/Makefile
	        data/scripts/Makefile
	        data/scripts/bsd-init
	        data/scripts/mind
	        data/scripts/logrotation
	        data/scripts/solaris-init
	        data/scripts/systemv-init
	        doc/Makefile
	        configs/mind.conf
	        configs/mindf1.conf
	        configs/Makefile
	        configs/lists/Makefile
	        configs/lists/phraselists/Makefile
	        configs/lists/blacklists/Makefile
	        configs/lists/contentscanners/Makefile
	        configs/lists/weightedphraselist
	        configs/lists/exceptionphraselist
	        configs/lists/bannedphraselist
		configs/lists/bannedurllist
		configs/lists/bannedsitelist
	        configs/downloadmanagers/Makefile
	        configs/downloadmanagers/default.conf
	        configs/downloadmanagers/fancy.conf
	        configs/downloadmanagers/trickle.conf
	        configs/contentscanners/Makefile
	        configs/contentscanners/clamav.conf
	        configs/contentscanners/clamdscan.conf
	        configs/contentscanners/icapscan.conf
	        configs/contentscanners/kavav.conf
	        configs/contentscanners/kavdscan.conf
	        configs/contentscanners/commandlinescan.conf
		configs/authplugins/Makefile
		configs/authplugins/ip.conf
		configs/lists/authplugins/Makefile
		configs/lists/downloadmanagers/Makefile
                src/Makefile
		])

AC_OUTPUT

ln -s --force /usr/bin/libtool .
